package com.climaxi.core;

import com.pcr.android.R;

import android.app.Activity;
import android.content.Context;
import android.content.ContentResolver;
import android.provider.Settings;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.view.WindowManager;

public class Page {

	public static void ChangePage() 
	{
		
	}

	public static void LockScreenRotation(ContentResolver resolver, Boolean enabled)
	{
		Settings.System.putInt(resolver, Settings.System.ACCELEROMETER_ROTATION, enabled ? 1 : 0);
		
	}
	public static boolean isEnabledScreenRotation(final ContentResolver resolver) {
		return 1 == Settings.System.getInt(resolver,Settings.System.ACCELEROMETER_ROTATION, 1);
	}
	
	
	public static void setScreenBrightness(Activity activity, float n)
	{
		WindowManager.LayoutParams layout;
    	layout = activity.getWindow().getAttributes();
    	layout.screenBrightness = n;
    	activity.getWindow().setAttributes(layout);
    	ClimaxiLog.Trace("setScreenBrightness " + n);
	}
	
	public static void playSoundButtonClick(Context context)
	{
		MediaPlayer mp = MediaPlayer.create(context, R.raw.pin);
		mp.setVolume(0.2F, 0.2F);
		mp.setOnCompletionListener(new OnCompletionListener() {

            public void onCompletion(MediaPlayer mp) {
                // TODO Auto-generated method stub
                mp.release();
            }
        });   
        mp.start();
	}

	public static void playSoundCheckBox(Context context)
	{
		MediaPlayer mp = MediaPlayer.create(context, R.raw.sound_3);
		mp.setVolume(0.3F, 0.3F);
		mp.setOnCompletionListener(new OnCompletionListener() {

            public void onCompletion(MediaPlayer mp) {
                // TODO Auto-generated method stub
                mp.release();
            }

        });   
        mp.start();
	}
	
	public static void playSoundRadioBox(Context context)
	{
		MediaPlayer mp = MediaPlayer.create(context, R.raw.sound_3);
		mp.setVolume(0.3F, 0.3F);
		mp.setOnCompletionListener(new OnCompletionListener() {

            public void onCompletion(MediaPlayer mp) {
                // TODO Auto-generated method stub
                mp.release();
            }

        });   
        mp.start();
	}
	
	public static void playSoundClickItem(Context context)
	{
		MediaPlayer mp = MediaPlayer.create(context, R.raw.sound_1);
		mp.setVolume(0.5F, 0.5F);
		mp.setOnCompletionListener(new OnCompletionListener() {

            public void onCompletion(MediaPlayer mp) {
                // TODO Auto-generated method stub
                mp.release();
            }

        });   
        mp.start();
	}
	
	public static void hideStatusBar(Activity activity) {
        WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
        attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
        activity.getWindow().setAttributes(attrs);
    }

	public static void showStatusBar(Activity activity) {
        WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
        attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
        activity.getWindow().setAttributes(attrs);
    }
}
